package responsechain.factory.impl;

import responsechain.handeler.Interview;
import responsechain.factory.ChainFactory;
import responsechain.handeler.Handler;
import responsechain.handeler.impl.OfficalPart;
import responsechain.handeler.impl.ProductionPart;
import responsechain.handeler.impl.PublicRelationPart;

public class InterviewFactory extends ChainFactory {

    @Override
    public Handler getResponseChainHeader() {
        HeaderChain headerChain = new HeaderChain();
        headerChain
                .buildNext(new PublicRelationPart())
                .buildNext(new ProductionPart())
                .buildNext(new OfficalPart());
        return headerChain;
    }

    static class HeaderChain extends Handler {

        @Override
        public boolean handle(Interview interview) {
            String name = interview.getName();
            log.i(name +":即将进入招聘责任链");
            boolean next = next(interview);
            if (next){
                log.i(name+":被成功招聘");
            }
            log.i(name+":没有被招聘");
            return next;
        }



        @Override
        protected String getPartName() {
            return "责任链头节点";
        }

        @Override
        public void employee() {
            getNext().employee();
        }

        @Override
        public int getHc() {
            return 0;
        }

    }
}
